home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / phpMyAdmin / libraries / select_theme.lib.php < prev    next >
PHP Script  |  2005-03-06  |  4KB  |  103 lines

  1. <?php
  2. /* $Id: select_theme.lib.php,v 2.10 2005/03/06 21:10:53 nijel Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5. /**
  6.  * phpMyAdmin Theme Manager
  7.  * 2004-05-20: Michael Keck <mail_at_michaelkeck_dot_de>
  8.  *
  9.  * The theme manager checks the directory /themes/ for subdirectories
  10.  * which are the themes.
  11.  * If you're building a new theme for PMA, your theme should include
  12.  * make a folder theme_name/ in the directory /themes which includes
  13.  * a subdirectory css/.
  14.  * In the css-directory you should (if you want) edit the follow files:
  15.  *    - theme_left.css.php      // includes css-styles for the left frame
  16.  *    - theme_right.css.php     // includes css-styles for the main frame
  17.  *    - theme_print.css.php     // includes css-styles for printing
  18.  *
  19.  * If you want to use default themes for left, right or print
  20.  * so you need not to build the css-file and PMA will use its own css.
  21.  * If you want to use own images for your theme, you should make all
  22.  * images (buttons, symbols, arrows) wich are included in the default
  23.  * images directory PMA and store them into the subdirectory /img/ of
  24.  * your theme.
  25.  * Note:
  26.  *     The images must be named as in the default images directory of
  27.  *     PMA and they must have the same size in pixels.
  28.  *     You can only use own images, if you've edit own css files.
  29.  */
  30.  
  31. /**
  32.  * We need some elements of the superglobal $_SERVER array.
  33.  */
  34. require_once('./libraries/grab_globals.lib.php');
  35. global $PHP_SELF;
  36. /**
  37.  * theme manager
  38.  */
  39. $PMA_ThemeDefault = FALSE;
  40. $PMA_ThemeAvailable = FALSE;
  41. if ($cfg['ThemeManager']){
  42.     $PMA_ThemeAvailable = TRUE;
  43. }
  44.  
  45. if ($PMA_ThemeAvailable == TRUE){ // check after default theme
  46.     $tmp_path_default = $cfg['ThemePath'] . '/' .$cfg['ThemeDefault'];
  47.     if (isset($cfg['ThemeDefault']) && is_dir($tmp_path_default)){
  48.         $PMA_ThemeDefault = TRUE;
  49.     }
  50. } // end check default theme
  51.  
  52. if ($PMA_ThemeAvailable == TRUE) { // themeManager is available
  53.     if ($handleThemes = opendir($cfg['ThemePath'])) { // check for themes directory
  54.         while (FALSE !== ($PMA_Theme = readdir($handleThemes))) { // get themes
  55.             if ($PMA_Theme != "." && $PMA_Theme != ".." && $PMA_Theme != 'CVS') { // file check
  56.                 if (@is_dir($cfg['ThemePath'].'/'.$PMA_Theme)) { // check the theme
  57.                     // check for theme requires/name
  58.                     unset($theme_name, $theme_generation, $theme_version);
  59.                     @include($cfg['ThemePath'] . '/' . $PMA_Theme . '/info.inc.php');
  60.  
  61.                     // did it set correctly?
  62.                     if (!isset($theme_name, $theme_version, $theme_generation))
  63.                         continue; // invalid theme
  64.  
  65.                     if ($theme_generation != PMA_THEME_GENERATION)
  66.                         continue; // different generation
  67.  
  68.                     if ($theme_version < PMA_THEME_VERSION)
  69.                         continue; // too old version
  70.  
  71.                     $available_themes_choices[]=$PMA_Theme;
  72.                     $available_themes_choices_names[$PMA_Theme] = $theme_name;
  73.                 } // end check the theme
  74.             } // end file check
  75.         } // end get themes
  76.     } // end check for themes directory
  77.     closedir($handleThemes);
  78. } // end themeManger
  79.  
  80. if (isset($set_theme)) { // if user submit a theme
  81.     setcookie('pma_theme', $set_theme, time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
  82. } else { // else check if user have a theme cookie
  83.     if (!isset($_COOKIE['pma_theme']) || empty($_COOKIE['pma_theme'])) {
  84.         if ($PMA_ThemeDefault == TRUE) {
  85.             if (basename($PHP_SELF) == 'index.php') {
  86.                 setcookie('pma_theme', $cfg['ThemeDefault'], time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
  87.             }
  88.             $pmaTheme=$cfg['ThemeDefault'];
  89.         }else{
  90.             if (basename($PHP_SELF) == 'index.php') {
  91.                 setcookie('pma_theme', 'original', time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
  92.             }
  93.             $pmaTheme='original';
  94.         }
  95.     } else {
  96.         $pmaTheme=$_COOKIE['pma_theme'];
  97.         if (basename($PHP_SELF) == 'index.php') {
  98.             setcookie('pma_theme', $pmaTheme, time() + 60*60*24*30, $GLOBALS['cookie_path'], '', $GLOBALS['is_https']);
  99.         }
  100.     }
  101. } // end if
  102. ?>
  103.